import de.ruedigermoeller.fastcast.samples.benchmark.BenchFeeder;
import de.ruedigermoeller.fastcast.samples.benchmark.BenchTopicService;
import de.ruedigermoeller.fastcast.service.fcdemon.FCDemon;
import de.ruedigermoeller.fastcast.service.fcdemon.FCStartScript;
import java.lang.Exception;
import java.lang.Integer;
import java.util.List;

/**
 * fcon -j BigTest
 * can be changed without recompile. No Generics support (janino)
 */
public class SampleBench extends FCStartScript {

    public void startCluster(String arg, List demons) {
        String args[] = arg.split(" ");
        try {
            int numSender = 1;
            int numReceiver = 1;
            String sender = "1";
            try {
                numSender = Integer.parseInt(args[0]);
            } catch (Exception e) {

            }
            try {
                numReceiver = Integer.parseInt(args[1]);
            } catch (Exception e) {

            }

            String opts = "-Xms2g -Xmx2g -XX:+UseConcMarkSweepGC -XX:-UseAdaptiveSizePolicy -XX:SurvivorRatio=8 -XX:NewRatio=2 ";

            for ( int i = 0; i < numSender; i++) {
                System.out.println("Starting Sender node "+BenchFeeder.class.getName()+"-"+i);
                FCDemon.ProcessEntry en = startNode(opts,BenchFeeder.class, "");
                if ( en == null ) {
                    System.out.println("   failed");
                }
            }
            for ( int i = 0; i < numReceiver; i++) {
                System.out.println("Starting Receiver node "+BenchTopicService.class.getName()+"-"+i);
                FCDemon.ProcessEntry en = startNode(opts,BenchTopicService.class, "");
                if ( en == null ) {
                    System.out.println("   failed");
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
